import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAO151B99xn25rjCUrUIwvtx1m7zQYfRd\n' +
'WQ1nseM/OPIhAyM8AmCcrPar8hhQyJ8GOuwoL9iEeCoTlQKNNfw00fsCAwEAAQ=='

const privateKey = 'MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA7XnUH33GfbmuMJSt\n' +
'QjC+3HWbvNBh9F1ZDWex4z848iEDIzwCYJys9qvyGFDInwY67Cgv2IR4KhOVAo01\n' +
'/DTR+wIDAQABAkEA0nZgWrB7k71V9VQu4TSWUoggyAveZFW+sLSv4PiNHXgTHDkS\n' +
'aMlRaQ3nRWEuuyPbkO+yHxKGOwbaaA9R/X/fYQIhAP/G5s5nXqsCxzYCpNI+eFYb\n' +
'XpDtdkaT16BXU73R0t8ZAiEA7a7XcZVHqMk9eaFu+pkizfjbBqazO8dz/LaJFl3x\n' +
'YDMCIQC6Bb73ftarKWoZLfMRtb1vYph0b0AGNKAuTVTqSSBEgQIgfk6aqP6GfTis\n' +
'FZXnTv7QExr68fbmao8coSAzi5JSsicCIGge8viDfXpOYeByOITZVV+E+qryD/FR\n' +
'0nW+HaVnWsp4'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

